# -*- coding: utf-8 -*-
"""
---------------------------------------
@File    ：application.py
@Author  ：liyunhui
@Date    ：2024/9/13 下午4:11 
@explain : 文件说明
---------------------------------------
"""
import tornado.web
import tornado.ioloop
from config import config
from views.ip_get import IpGetHandler
from views.ip_call import IpCallHandler
from views.ip_check import IpCheckHandler
from views.ip_update import IpUpdateHandler
from tornado_swagger.setup import setup_swagger


class Application(tornado.web.Application):
    # todo: 各个接口的路由在config配置文件中
    _routes = [
        # 获取全球航班的实时数据
        tornado.web.url(config.ip_get_route, IpGetHandler),
        tornado.web.url(config.ip_call_route, IpCallHandler),
        tornado.web.url(config.ip_check_route, IpCheckHandler),
        tornado.web.url(config.ip_update_route, IpUpdateHandler)
    ]

    def __init__(self):
        setup_swagger(self._routes)
        # 在设置Swagger之前，定义要隐藏的模型
        setup_swagger(
            self._routes,
            swagger_url='/ip_pool',
            api_base_url='/',
            display_models=False,
            title='IP代理池',
            description='IP代理池管理',
            security_definitions={}
        )
        super(Application, self).__init__(self._routes, **config.settings)
